package com.huawei.appgallery.forum.comments.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.huawei.appgallery.forum.base.ui.ForumActivity;
import com.huawei.appgallery.forum.comments.api.ICommentDetailProtocol;
import com.huawei.appgallery.forum.comments.api.ICommentDetailResult;
import com.huawei.hmf.annotation.ActivityDefine;
import o.bqx;
import o.btb;
import o.bue.b;
import o.bue.j;
import o.cbh;
import o.doo;
import o.evk;
import o.fho;
import o.fiu;
import o.fiv;
import o.fjb;
import o.fjc;
import o.fjf;
import o.fjo;
import o.fjq;

@ActivityDefine(alias = "comment.detail.activity", protocol = ICommentDetailProtocol.class, result = ICommentDetailResult.class)
public class CommentDetailTransgerActivity extends ForumActivity {
    private fiv ॱˊ = fiv.ॱ(this);

    public void onCreate(@Nullable Bundle bundle) {
        requestWindowFeature(1);
        super.onCreate(bundle);
        if (bundle != null) {
            finish();
            return;
        }
        View view = new View(this);
        view.setAlpha(0.0f);
        setContentView(view);
        getWindow().setBackgroundDrawableResource(b.ʽ);
        ICommentDetailProtocol iCommentDetailProtocol = (ICommentDetailProtocol) this.ॱˊ.ॱ();
        if (iCommentDetailProtocol == null) {
            bqx.ॱ("CommentDetailTransgerActivity", "protocol is null!");
            finish();
        } else if (!doo.ˊ((Context) this) && iCommentDetailProtocol.getNeedComment()) {
            evk.ˏ(getString(j.ˋॱ));
            finish();
        } else if (!iCommentDetailProtocol.getNeedComment()) {
            ˊ(iCommentDetailProtocol);
        } else if (btb.ˊ(this, iCommentDetailProtocol.getCommentStatus(), false)) {
            ˋ(iCommentDetailProtocol);
        } else {
            finish();
        }
    }

    private void ˊ(ICommentDetailProtocol iCommentDetailProtocol) {
        fjb ˎ = fho.ˏ().ˋ("Comments").ˎ("comment.detail.inner.activity");
        ICommentDetailProtocol iCommentDetailProtocol2 = (ICommentDetailProtocol) ˎ.ˊ();
        iCommentDetailProtocol2.setUri(iCommentDetailProtocol.getUri());
        iCommentDetailProtocol2.setSourceType(iCommentDetailProtocol.getSourceType());
        iCommentDetailProtocol2.setNeedComment(iCommentDetailProtocol.getNeedComment());
        iCommentDetailProtocol2.setClickReplyView(iCommentDetailProtocol.getClickReplyView());
        iCommentDetailProtocol2.setErrorCode(iCommentDetailProtocol.getErrorCode());
        iCommentDetailProtocol2.setDomainId(iCommentDetailProtocol.getDomainId());
        fiu.ˊ().ॱ((Context) this, ˎ, new fjc<ICommentDetailResult>(this) {
            final /* synthetic */ CommentDetailTransgerActivity ˋ;

            {
                this.ˋ = r1;
            }

            public /* synthetic */ void ˎ(int i, Object obj) {
                ˋ(i, (ICommentDetailResult) obj);
            }

            public void ˋ(int i, ICommentDetailResult iCommentDetailResult) {
                ((CommentDetailTransgerActivity) ˊ()).ॱ(i, iCommentDetailResult);
            }
        });
    }

    private void ॱ(int i, ICommentDetailResult iCommentDetailResult) {
        if (i == -1 && iCommentDetailResult != null) {
            ˎ(iCommentDetailResult.getLike(), iCommentDetailResult.getLikeCount(), iCommentDetailResult.getReplyCount());
        }
        finish();
    }

    private void ˋ(final ICommentDetailProtocol iCommentDetailProtocol) {
        ((cbh) fho.ˏ().ˋ("User").ॱ(cbh.class)).ˎ(this, 15).ˏ(new fjq<Boolean>(this) {
            final /* synthetic */ CommentDetailTransgerActivity ˏ;

            public void onComplete(fjo<Boolean> o_fjo_java_lang_Boolean) {
                if (o_fjo_java_lang_Boolean.ˊ() && ((Boolean) o_fjo_java_lang_Boolean.ॱ()).booleanValue()) {
                    this.ˏ.ˊ(iCommentDetailProtocol);
                    return;
                }
                bqx.ˏ("CommentDetailTransgerActivity", "check user fail");
                this.ˏ.finish();
            }
        });
    }

    private void ˎ(boolean z, long j, int i) {
        fjf ˊ = fjf.ˊ(this);
        ICommentDetailResult iCommentDetailResult = (ICommentDetailResult) ˊ.ॱ();
        iCommentDetailResult.setLike(z);
        iCommentDetailResult.setLikeCount(j);
        iCommentDetailResult.setReplyCount(i);
        setResult(-1, ˊ.ˊ());
    }
}
